﻿@model Forest.Cat.Admin.Models.CoverLetters.CoverLetterListModel       
@using Forest.Cat.Admin.Extensions;
@{
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";    
}
<div class="savedsearch_manage_right">
    <div class="savedsearch_manage_right_title">
        求职信</div>
    <div class="savedsearch_manage_right_box">
        <p>
            <b>您已经创建了 @Model.CoverLetters.Count 个求职信</b><span>（最多可订阅10个）</span>
            @if (Model.CoverLetters.Count < 10)
            { <a href="@Url.Action("Create")"><img src="@Url.Content("~/Administration/Content/images/cl-built-86-19.jpg")" /></a>
            }</p>
        <table cellpadding="0" cellspacing="0" class="rebook_tab" width="100%">
            <tr>
                <th>
                    <input type="checkbox" class="checkboxHeader" />
                </th>
                <th>
                    求职信名称
                </th>
                <th>
                    最近修改
                </th>
                <th>
                    操作
                </th>
            </tr>
            @foreach (var cl in Model.CoverLetters)
            {
                <tr id=	'@cl.Id'>
                    <td style="text-align: center; width: 30px;">
                        <input type="checkbox" class="checkboxItem" />
                    </td>
                    <td>@Html.ActionLink(cl.Title, "Edit", new { cl.Id })
                    </td>
                    <td style="text-align: center;">@cl.LastUpdated
                    </td>
                    <td style="text-align: center;">
                        @using (Html.BeginForm("CoverLetterDelete", "CoverLetter", FormMethod.Post))
                        {
                            @Html.Hidden("deleteId", cl.Id.ToString())
                            @Html.ActionLink("修改", "Edit", "CoverLetter", new { cl.Id }, null) @:|
                        <input type="submit" value="删除" onclick="return confirm('确定删除？');" />
                        }
                    </td>
                </tr>

            }
        </table>
        <div class="pages">
            <p>
                <a href="#">
                    @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
                </a>
            </p>
            @using (Html.BeginForm("CoverLetterDeleteList", "CoverLetter", FormMethod.Post))
            {
                @Html.Hidden("deleteIds", "")
                <input type="submit" value="删除所选记录" onclick="return GetSelectCheckBox();" />
              
            }
        </div>
    </div>
</div>
<script type="text/javascript" language="javascript">
    $(window).bind('load', function () {
        var cbHeader = $(".checkboxHeader");
        var cbRowItem = $(".checkboxItem");
        cbHeader.bind("click", function () {
            cbRowItem.each(function () { this.checked = cbHeader[0].checked; })
        });
        cbRowItem.bind("click", function () { if ($(this).checked == false) cbHeader[0].checked = false; });
    });

    function GetSelectCheckBox() {
        var ckList = $(".checkboxItem");
        var cknum = 0;
        var idList = new Array();
        ckList.each(function () {
            if (this.checked) {
                var id = $(this).parent().parent().attr("id");
                idList[cknum] = id;
                cknum = cknum + 1;
            }
        });

        if (cknum == 0) {
            alert("请至少选择一个checkbox");
            return false;
        }

        $("#deleteIds").val(idList);
        return confirm("确定删除？");
    }
</script>
